package com.gome.han.beencloud.jdk.bio.echo.demo2;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

/**
* @author hanpeng
* @version 创建时间：2020年11月1日 下午9:24:21
* @ClassName 类名称
* @Description 类描述
*/
public class Client {
	public static void main(String[] args) throws UnknownHostException, IOException, InterruptedException {
		final int length = 100;
		String host = "localhost";
		int port = 8000;
		
		Socket[] sockets = new Socket[length];
		for(int i = 0; i < length; i++) {
			sockets[i] = new Socket(host, port);
			System.out.println("the " + (i+1) + "connection is successful");
		}
		
		Thread.sleep(3000);
		for(int i = 0; i < length; i++) {
			sockets[i].close();
		}

	}
}
